﻿using System.Collections.Generic;
using BSDS.Commands.Commands.Implementation.Jobs;
using BSDS.Core.Model.Services;
using BSDS.Core.Model.Services.Geocoding;
using BSDS.Core.Model.Services.Jobs;
using BSDS.Core.Model.Services.Uploading;

namespace BSDS.Commands.Commands.Creation.Implementation.Jobs
{
    public class WaitJobCommandCreator : CommandCreatorBase
    {
        private readonly JobRepository repository;
        private readonly GeocodingService geocodingService;
        private readonly UploadService uploadService;
        private readonly DownloadService downloadService;
        private readonly JobService jobService;

        public WaitJobCommandCreator(JobRepository repository, GeocodingService geocodingService, 
            UploadService uploadService, DownloadService downloadService, JobService jobService)
        {
            this.repository = repository;
            this.geocodingService = geocodingService;
            this.uploadService = uploadService;
            this.downloadService = downloadService;
            this.jobService = jobService;
        }

        protected override bool Supports(Dictionary<string, string> parameters)
        {
            return parameters.Keys.Count == 1 && parameters.ContainsKey("waitjob");
        }

        protected override ICommand Create(Dictionary<string, string> parameters)
        {
            var jobId = parameters["waitjob"];

            return new WaitJobCommand(jobId, repository, geocodingService, uploadService, downloadService, jobService);
        }
    }
}